

<extend name="./Application/Admin/View/layout.html"/>
<block name="content">


            <!-- start: Content -->
            <div id="content" class="span10">


            <ul class="breadcrumb">
                <li>
                    <i class="icon-home"></i>
                    <a href="index.html">后台</a>
                    <i class="icon-angle-right"></i>
                </li>
                <li>
                    <i class="icon-edit"></i>
                    <a href="#">管理员添加</a>
                </li>
            </ul>

            <div class="row-fluid sortable">
                <div class="box span12">
                    <div class="box-header" data-original-title>
                        <h2><i class="halflings-icon white edit"></i><span class="break"></span>管理员添加</h2>
                        <div class="box-icon">
                            <a href="#" class="btn-setting"><i class="halflings-icon white wrench"></i></a>
                            <a href="#" class="btn-minimize"><i class="halflings-icon white chevron-up"></i></a>
                            <a href="#" class="btn-close"><i class="halflings-icon white remove"></i></a>
                        </div>
                    </div>
                    <div class="box-content">
                        <form class="form-horizontal" enctype="multipart/form-data" id="signupfrom" method="post" action="">
                          <fieldset>
                            <div class="control-group">
                              <label class="control-label" for="typeahead">头像 </label>
                              <div class="controls">
                              <notempty name="list['avatar']">
                                <img src="__IMG__{$list.avatar}" width="100px" height="100px" alt="">
                                <a class="btn btn-danger" href="{:U('admin/delavatar?id='.$list['id'])}">删除</a>
                                <else/>
                                <input type="file" name="avatar" class="span2 typeahead"   data-provide="typeahead" data-items="4" />
                                <span></span>
                                </notempty>
                              </div>
                            </div>
                            <div class="control-group">
                              <label class="control-label" for="typeahead">帐号 </label>
                              <div class="controls">
                                <input type="text" id="username" name="username" class="span2 typeahead"   data-provide="typeahead" data-items="4" value="{$list['username']}" >
                                <span></span>
                              </div>
                            </div>
                            <div class="control-group">
                              <label class="control-label" for="typeahead">邮箱 </label>
                              <div class="controls">
                                <input type="text" id="email" name="email" class="span2 typeahead"   data-provide="typeahead" data-items="4" value="{$list['email']}" >
                                   <span></span>
                              </div>
                            </div>
                            <div class="control-group">
                              <label class="control-label" for="typeahead">手机 </label>
                              <div class="controls">
                                <input type="text" id="phone" name="phone" class="span2 typeahead"   data-provide="typeahead" data-items="4" value="{$list['phone']}" >
                                   <span></span>
                              </div>
                            </div>
                            <div class="form-actions">
                              <input type="hidden" name="" value="{$list['id']}" placeholder="">
                              <input type="hidden" name="" value="{$list['avatar']}" placeholder="">
                              <button type="submit" class="btn btn-primary">保存</button>
                              <button type="reset" class="btn">清空</button>
                            </div>
                          </fieldset>
                        </form>

                    </div>
                </div><!--/span-->

            </div><!--/row-->
            <div class="row-fluid">
      </div>




    </div><!--/.fluid-container-->

            <!-- end: Content -->
</block>
<block name="js">
  <script src="__ADMIN__js/jquery-1.9.1.min.js"></script>
  <script src="__ADMIN__js/jquery.validate.min.js"></script>
  <script  type="text/javascript">
          $(function(){

            jQuery.validator.addMethod("isMobile", function(value, element) {
                var length = value.length;
                var mobile = /^(13[0-9]{9})|(18[0-9]{9})|(14[0-9]{9})|(17[0-9]{9})|(15[0-9]{9})$/;
                return this.optional(element) || (length == 11 && mobile.test(value));
            }, "请正确填写您的手机号码");

            $('#signupfrom').validate({
                // onfocusout:false,
                rules: {
                    username: {
                      required: true,
                      minlength: 3
                    },
                     password: {
                      required: true,
                      minlength: 3
                    },
                     password1: {
                      required: true,
                      equalTo:"#password"

                    },
                    phone: {
                      required: true,
                      minlength: 11,
                      isMobile:true,
                    },



                },
                messages: {

                    username: {
                      required: "请输入用户名",
                      minlength: "最少需要3个字符"
                    },
                     password: {
                      required: "请输入密码",
                      minlength: "最少需要3个字符"
                    },
                    password1: {
                      required: "请输入确认密码",
                      equalTo:"与密码不一致"

                    },
                     phone: {
                      required: "请输入手机号",
                      minlength: "确认手机不能小于11个字符",
                      isMobile : "请正确填写您的手机号码"
                    },


              },
              // errorElement:'span'
              // errorPlacement: function(error, element) {
              //     error.appendTo(element.parent());
              // }
            });
              var s=60;
              var time=0;

              $('#btn_sms').click(function(){
                var phone=$('#phone').val();
                var code=$(this);
                $.ajax({
                    url: "{:U('Admin/ajax/send_sms')}",
                    type: 'post',
                    data:{
                      'phone':phone
                    },
                    success: function(e){
                      alert(e);
                        if(e>0){
                          alert('发送成功');
                        }else{
                          alert('发送失败');
                        }
                    }

                })

                time=setInterval(function(){
                  if(s>0){
                    var txt=s+'秒后重新发送';
                    code.val(txt);
                    code.attr('disabled','disabled');
                    s--;
                  }else{
                    s=60;
                    var txt='手机发送验证码';
                     code.val(txt);
                     code.attr('disabled',false);
                     clearInterval(time);
                  }

                },1000);
              })
          })
  </script>
</block>